package com.inf.controller;

import com.inf.service.FrequencyStatsService;
import com.inf.utils.Tools;
import com.inf.vo.ResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by zhangbn on 2018/11/29.
 */
@RestController
@RequestMapping("/personface/fraq")
public class FrequencyStatsController {

    @Autowired
    FrequencyStatsService frequencyStatsService;


    /**
     * 频次统计接口
     *
     * @param beginTime
     * @param endTime
     * @param cameraIds
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getfraqstate", method = RequestMethod.POST)
    public ResponseVo frequencyStats(@RequestParam String beginTime, @RequestParam String endTime, @RequestParam String cameraIds) throws Exception {
        beginTime = Tools.formatTimeStr(beginTime, "yyMMdd");
        endTime = Tools.formatTimeStr(endTime, "yyMMdd");
        Map<String, Object> data = frequencyStatsService.frequencyStats(beginTime, endTime, cameraIds);
        ResponseVo rstVo = new ResponseVo();
        rstVo.setData(data);
        return rstVo;
    }

    /**
     * 频次统计下钻接口
     *
     * @param beginTime
     * @param endTime
     * @param cameraIds
     * @param uuid
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getfraqdetailbyuuid", method = RequestMethod.POST)
    public ResponseVo frequencyStatsDetail(@RequestParam String beginTime, @RequestParam String endTime, @RequestParam String cameraIds, String uuid) throws Exception {
        beginTime = Tools.formatTimeStr(beginTime, "yyMMdd");
        endTime = Tools.formatTimeStr(endTime, "yyMMdd");
        List<Map<String, Object>> data = frequencyStatsService.frequencyStatsDetail(beginTime, endTime, cameraIds, uuid);
        ResponseVo rstVo = new ResponseVo();
        rstVo.setData(data);
        return rstVo;
    }
}
